Repository navigation
feat(interpreter): child shells count SHLVL like bash - #2622
Merged
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 7e574b6 | Commit Preview URL Branch Preview URL |
Oct 08 2026, 03:22 AM |
bash and sh children raise the inherited SHLVL by one, apply bash's non-numeric, negative and >999 rules (with its warning), and export it. A child's output no longer streams past the bash command's own output redirects. The spec comparison runs real bash without the runner's SHLVL.
chaliy
force-pushed
the
claude/shlvl-var
branch
from
October 8, 2026 03:21
7ffe47b to
7e574b6
Compare
chaliy
added a commit
that referenced
this pull request
Oct 8, 2026
Shell diagnostics now read like non-interactive bash: `SCRIPT: line 2: x: command not found`, `bash: line 1: type: h: not found` under -c, instead of a bare `bash: `. The name is BASH_SOURCE[0] when a file is being read (a sourced file names itself), else $0. - Interpreter messages go through Interpreter::diag_prefix / diag. - Bundled builtins keep their `bash: name:` / `name:` text; the builtin dispatch point rewrites the line start before redirects or streaming see it. Usage lines, coreutils-style builtins and execution plans are untouched. - eval syntax errors read `$0: eval: line N:`; failglob, arithmetic and write-error messages honor $0. - `source missing` ends with a newline and reports the missing path; `source` with no operand exits 2 with bash's usage line. - Redirect failures on while/for/if/case report the closing line. - `set -u` names a bare positional `$2` like bash. - Child shells (bash -c, scripts by path) get their own name and lines. - Bash::set_interactive (used by the CLI REPL and Terminal) keeps the `bash: msg` form of `bash -i`. bash-oracle: match 92 -> 98, strict 71 -> 89 of 106 (with #2622) (floors raised).
3 tasks done
chaliy
added a commit
that referenced
this pull request
Oct 8, 2026
Shell diagnostics now read like non-interactive bash: `SCRIPT: line 2: x: command not found`, `bash: line 1: type: h: not found` under -c, instead of a bare `bash: `. The name is BASH_SOURCE[0] when a file is being read (a sourced file names itself), else $0. - Interpreter messages go through Interpreter::diag_prefix / diag. - Bundled builtins keep their `bash: name:` / `name:` text; the builtin dispatch point rewrites the line start before redirects or streaming see it. Usage lines, coreutils-style builtins and execution plans are untouched. - eval syntax errors read `$0: eval: line N:`; failglob, arithmetic and write-error messages honor $0. - `source missing` ends with a newline and reports the missing path; `source` with no operand exits 2 with bash's usage line. - Redirect failures on while/for/if/case report the closing line. - `set -u` names a bare positional `$2` like bash. - Child shells (bash -c, scripts by path) get their own name and lines. - Bash::set_interactive (used by the CLI REPL and Terminal) keeps the `bash: msg` form of `bash -i`. bash-oracle: match 92 -> 98, strict 71 -> 89 of 106 (with #2622) (floors raised).
chaliy
added a commit
that referenced
this pull request
Oct 8, 2026
Shell diagnostics now read like non-interactive bash: `SCRIPT: line 2: x: command not found`, `bash: line 1: type: h: not found` under -c, instead of a bare `bash: `. The name is BASH_SOURCE[0] when a file is being read (a sourced file names itself), else $0. - Interpreter messages go through Interpreter::diag_prefix / diag. - Bundled builtins keep their `bash: name:` / `name:` text; the builtin dispatch point rewrites the line start before redirects or streaming see it. Usage lines, coreutils-style builtins and execution plans are untouched. - eval syntax errors read `$0: eval: line N:`; failglob, arithmetic and write-error messages honor $0. - `source missing` ends with a newline and reports the missing path; `source` with no operand exits 2 with bash's usage line. - Redirect failures on while/for/if/case report the closing line. - `set -u` names a bare positional `$2` like bash. - Child shells (bash -c, scripts by path) get their own name and lines. - Bash::set_interactive (used by the CLI REPL and Terminal) keeps the `bash: msg` form of `bash -i`. bash-oracle: match 92 -> 98, strict 71 -> 89 of 106 (with #2622) (floors raised).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Михайло · project thread
What changed
bash/shchild shells count$SHLVLthe way bash'sadjust_shell_leveldoes: inherited level + 1, non-numeric counts as 0, negative lands on 0, past 999 restarts at 1 with bash'sshell level (N) too highwarning. The value is exported, so grandchildren andenvsee it.bashcommand's own output redirects.SHLVL, since a bashkit script is a top-level shell.Why
Bash-oracle gap
shlvl-nesting, and a real leak:bash -c 'echo leak >&2' 2>/dev/nullprintedleakin streaming mode.Before / After
8 spec cases (verified with
env -u SHLVL bashand bybash_comparison_tests) plus integration tests for the warning, its redirection and streaming.Risk
Low. bash's fork suppression (a sole
bash -ccommand execs without raising the level) is not modeled; documented in L-PROC-003.Checklist
-D warningsbash_comparison_testsgreenGenerated by Claude Code